<template>
  <div>
    <detail-banner :sightName="sightName" :bannerImg="bannerImg" :bannerImgs="gallaryImgs"></detail-banner>

    <detail-header></detail-header>

    <detail-list :list="list"></detail-list>
    <div class="content"></div>
  </div>
</template>

<script>
import axios from 'axios'
import detailBanner from './components/Banner.vue'
import detailHeader from './components/Header.vue'
import detailList from './components/List.vue'

export default {
  name: 'detail',
  components: { detailBanner, detailHeader, detailList },
  data() {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      list: []
    }
  },
  methods: {
    getdetailInfo() {
      // axios.get('/api/detail.json?id=' + this.$route.params.id)
      axios
        .get('/api/detail.json', {
          // ajax获取动态详情数据，替换写死的数据
          //  \static\mock\detail.json
          params: {
            id: this.$route.params.id
          }
        })
        .then(this.handlegetdataSucc)
    },
    handlegetdataSucc(res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        console.log(data)
        this.sightName = data.sightName
        this.bannerImg = data.bannerImg
        this.gallaryImgs = data.gallaryImgs
        this.list = data.categoryList
      }
    }
  },
  mounted() {
    this.getdetailInfo()
  }
}
</script>

<style scoped>
.content {
  height: 50rem;
}
</style>